#include <iostream>
using std::cout;
using std::endl;
/*
9、Write a class that has a const member function and a non-const member function. 
Write three functions that take an object of that class as an argument; 
the first takes it by value, the second by reference, 
and the third by const reference. Inside the functions, 
try to call both member functions of your class and explain the results.
*/

class C1{
public:
    void const_fun() const{
        cout << "the const member function is called." << endl;
    }
    void non_const_fun(){
        cout << "the non-const member function is called." << endl;
    }
};

void fun1(C1 c1){
    c1.const_fun();
    c1.non_const_fun();
}

void fun2(C1 &c1){
    c1.const_fun();
    c1.non_const_fun();
}

void fun3(const C1 &c1){
    c1.const_fun();
    // error:  c1.non_const_fun();
}

int main(){
    C1 c1;
    fun1(c1);
    cout << "-----------------------------------------" << endl;
    
    fun2(c1);
    cout << "-----------------------------------------" << endl;
    
    fun3(c1);
    cout << "常量对象，不可以调用非常量成员函数。" << endl;
    return 0;
}